package se.olli.jonsered;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MainMenuAdapter extends BaseAdapter {
	private final Context context;
	private LayoutInflater inflater;
	private String[] values;
	private Integer[] mThumbIds;
	
	public MainMenuAdapter(Context c, String[] textVals, Integer[] thumbs) {
		context = c;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		mThumbIds = thumbs;
		values = textVals;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		View rowView = convertView;
		if (convertView == null)
			rowView = inflater.inflate(R.layout.main_menu_layout, null);
		
		TextView textView = (TextView) rowView.findViewById(R.id.label);
		ImageView imageView = (ImageView) rowView.findViewById(R.id.menu_img);
		textView.setText(values[position]);

		imageView.setImageResource(mThumbIds[position]);
		
		return rowView;
	}

	public int getCount() {
		return mThumbIds.length;
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

}
